<template>
  <el-form :inline="true" :model="formInline" class="form-inline">
    <el-form-item label="巡检人员：">
      <el-input
        v-model="formInline.patrolPerson"
        placeholder="--请输入--"
      ></el-input>
    </el-form-item>
    <el-form-item label="巡检点类型" prop="patrolPointType">
      <el-select v-model="formInline.patrolPointType" placeholder="--请选择--">
        <el-option
          v-for="item in pipeNameDropList"
          :key="item"
          :label="item"
          :value="item"
        />
      </el-select>
    </el-form-item>
    <el-form-item label="巡检时间：">
      <el-date-picker
        v-model="date"
        type="datetimerange"
        format="YYYY-MM-DD HH:mm:ss"
        value-format="YYYY-MM-DD HH:mm:ss"
        range-separator="~"
        start-placeholder="开始时间"
        end-placeholder="结束时间"
        @change="dateChange"
        size="small"
      />
    </el-form-item>
    <el-form-item class="btns">
      <el-button type="primary" @click="onSubmit">查询</el-button>
      <el-button type="success" class="m-left" @click="onClear">清空</el-button>
    </el-form-item>
  </el-form>
</template>

<script setup>
import { reactive, defineEmits, ref, onMounted } from 'vue'
import { PmiPointTypeDrop } from '@/api/CheckingPoint'
const formInline = reactive({
  patrolPerson: '', //巡检人员
  patrolPointType: '', //巡检点类型
  time: '' //时间选择
})
const date = ref([])
const dateChange = (date) => {
  console.log('dateChange', date)
  formInline.time = date
}
const pipeNameDropList = ref([]) //下拉列表
const emits = defineEmits(['onSearch'])
const onSubmit = () => {
  emits('onSearch', formInline)
}
onMounted(() => {
  GetPmiPointTypeDrop()
})
const onClear = () => {
  formInline.patrolPerson = ''
  formInline.patrolPointType = ''
  formInline.time = ''
  date.value = []
  emits('onSearch', formInline)
}
//获取巡检点类型下拉列表
const GetPmiPointTypeDrop = () => {
  PmiPointTypeDrop().then((res) => {
    pipeNameDropList.value = res
  })
}
</script>

<style lang="scss" scoped>
// :deep(.form-inline[data-v-d0e44f9c]) {
//   width: 90%;
//   /* position: relative; */
//   display: flex;
//   column-gap: 0.625rem;
//   flex-wrap: wrap;
// }
.form-inline {
  width: 100%;
  position: relative;
  display: flex;
  column-gap: 20px;
  flex-wrap: wrap;
  // padding-bottom: 33px;
  // margin-top: -5px;
  .btns {
    position: absolute;
    right: 0;
    top: 0px;
    .m-left {
      margin-left: 20px;
    }
  }
}
</style>
